package com.dks.controller.teacher;


import com.dks.dto.student.StudentEvaluateDto;
import com.dks.repository.IEvaluateRepository;
import com.dks.result.ResultModel;
import com.dks.vo.teacher.EvaluateDetailVo;
import com.dks.vo.teacher.EvaluateVo;
import com.dks.util.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/***
 * 教师评价相关
 */
@RestController
@RequestMapping("evaluate")
public class EvaluateController{

    @Autowired
    private IEvaluateRepository evaluateRepository;

    /***
     * 评价列表
     * @author evan
     */
    @GetMapping("list")
    public ResultModel<PageInfo<EvaluateVo>> list(@RequestParam(value = "teacherId")Long teacherId,
                                                  @RequestParam(value = "qsClassId", required = false)Long qsClassId,
                                                  @RequestParam(value = "studentId",required = false)Long studentId,
                                                  @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                  @RequestParam(value = "pageSize",defaultValue = "15") Integer pageSize){
        return evaluateRepository.list(teacherId, qsClassId, studentId, pageNum, pageSize);
    }

    /***
     * 评价详情
     * @author evan
     */
    @GetMapping("{id}")
    public ResultModel<EvaluateDetailVo> select(@PathVariable Long id){
        return evaluateRepository.select(id);
    }

    /***
     * 评价详情
     * @author evan
     */
    @PostMapping("add")
    public ResultModel<Object> addEvaluate(@RequestBody StudentEvaluateDto studentEvaluateDto){
        return evaluateRepository.addStudentEvaluate(studentEvaluateDto);
    }

    @GetMapping("labels")
    public ResultModel<Object> getAllLabels(){
        return evaluateRepository.getAllLabels();
    }

}
